﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace IPIdee.MapServices.Client.Entities.Coordinates
{
    [Serializable]
    public class LatLngCoordinate
    {
        public LatLngCoordinate()
        {
        }

        public LatLngCoordinate(double latitude, double longitude, int zoom)
        {
            this.Latitude = latitude;
            this.Longitude = longitude;
            this.Zoom = zoom;
        }

        public double Latitude
        {
            get;
            set;
        }

        public double Longitude
        {
            get;
            set;
        }

        public int Zoom
        {
            get;
            set;
        }

        public static implicit operator AbsMapSpotCoordinate(LatLngCoordinate sourceCoordinate)
        {
            var absoluteX = CoordinateConvertor.GetAbsoluteXOnZoom(sourceCoordinate.Longitude, sourceCoordinate.Zoom);
            var absoluteY = CoordinateConvertor.GetAbsoluteYOnZoom(sourceCoordinate.Latitude, sourceCoordinate.Zoom);
            var result = new AbsMapSpotCoordinate(absoluteX, absoluteY, sourceCoordinate.Zoom);

            return result;
        }

    }
}
